package com.vnt;
import org.kalmeo.kuix.core.model.DataProvider;
import java.io.IOException;
import javax.microedition.lcdui.*;
public class ContentList extends DataProvider {
	private static final String IMG_PROPERTY = "img";
	private static final String DATA_PROPERTY = "data";
	private static final String NAME_PROPERTY = "name";
	private static final String IMAGE_PROPERTY = "avatar";
	// Id used for update or delete shopList from the record store
	private final Pad pad = new Pad();
	public String img;
	public String data;
	// ShopList's name
	public String name;
	public Image avatar;
	 
	public void setImage(Image image)
	{
	         this.avatar = image;
	         dispatchUpdateEvent(IMAGE_PROPERTY);
	}

	public void setId(String img) {
		this.img = img;
		try {
			setAvatar(img);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dispatchUpdateEvent(IMG_PROPERTY);
	}
	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
		dispatchUpdateEvent(NAME_PROPERTY);
	}
	public void setAvatar(String img) throws IOException {
		this.avatar = pad.getImage(img);
	}
	public void setCode(String data) {
		this.data = data;
		dispatchUpdateEvent(DATA_PROPERTY);
	}

	/* (non-Javadoc)
	 * @see org.kalmeo.kuix.core.model.DataProvider#getUserDefinedValue(java.lang.String)
	 */
	protected Object getUserDefinedValue(String property) {
		if (NAME_PROPERTY.equals(property)) {
			return this.name;
		}
		if (DATA_PROPERTY.equals(property)) {
			return this.data;
		}
		if (IMG_PROPERTY.equals(property)) {
			return this.img;
		}
		 if (IMAGE_PROPERTY.equals(property))
         {
              return this.avatar;
         }
		return null;
	}
}
